<core-loading [hideUntil]="loaded">
    <div *ngIf="!summary">
        <ion-list-header text-wrap>
            <ion-avatar core-user-avatar [user]="profile" [courseId]="courseId" [userId]="profile && profile.id" item-start></ion-avatar>
            <h2><core-format-text [text]="submission.title" contextLevel="module" [contextInstanceId]="module.id" [courseId]="courseId"></core-format-text></h2>
            <p *ngIf="profile && profile.fullname">{{profile.fullname}}</p>
            <p *ngIf="showGrade(submission.submissiongrade)" [class.addon-has-overriden-grade]="showGrade(submission.submissiongradeover)">
                {{ 'addon.mod_workshop.submissiongradeof' | translate:{$a: workshop.grade } }}: {{submission.submissiongrade}}
            </p>
            <p *ngIf="showGrade(submission.submissiongradeover)" class="addon-overriden-grade">
                {{ 'addon.mod_workshop.gradeover' | translate }}: {{submission.submissiongradeover}}
            </p>
            <p *ngIf="access.canviewallsubmissions && showGrade(submission.gradinggrade)">
                {{ 'addon.mod_workshop.gradinggradeof' | translate:{$a: workshop.gradinggrade } }}: {{submission.gradinggrade}}
            </p>
            <ion-note item-end *ngIf="!submission.timemodified">
                <ion-icon name="time"></ion-icon> {{ 'core.notsent' | translate }}
            </ion-note>
            <ion-note item-end *ngIf="submission.timemodified">
                {{submission.timemodified | coreDateDayOrTime}}
                <ng-container *ngIf="submission.offline"><ion-icon name="time"></ion-icon> {{ 'core.notsent' | translate }}</ng-container>
                <ng-container *ngIf="submission.deleted"><ion-icon name="trash"></ion-icon> {{ 'core.deletedoffline' | translate }}</ng-container>
            </ion-note>
        </ion-list-header>
        <ion-item text-wrap *ngIf="submission.content">
            <core-format-text [component]="component" [componentId]="componentId" [text]="submission.content" contextLevel="module" [contextInstanceId]="module.id" [courseId]="courseId"></core-format-text>
        </ion-item>
        <core-files [files]="submission.attachmentfiles" [component]="component" [componentId]="componentId"></core-files>
        <ion-item text-wrap *ngIf="viewDetails && submission.feedbackauthor">
            <ion-avatar *ngIf="evaluateByProfile" core-user-avatar [user]="evaluateByProfile" item-start [courseId]="courseId" [userId]="evaluateByProfile.id"></ion-avatar>

            <h2 *ngIf="evaluateByProfile && evaluateByProfile.fullname">{{ 'addon.mod_workshop.feedbackby' | translate : {$a: evaluateByProfile.fullname} }}</h2>
            <core-format-text [text]="submission.feedbackauthor" contextLevel="module" [contextInstanceId]="module.id" [courseId]="courseId"></core-format-text>
        </ion-item>
        <ion-item *ngIf="viewDetails">
            <button ion-button block (click)="gotoSubmission()">
                {{ 'core.showmore' | translate }}
                <ion-icon name="arrow-forward" item-end></ion-icon>
            </button>
        </ion-item>
    </div>

    <a ion-item text-wrap *ngIf="summary" [attr.detail-none]="submission.timemodified ? null : true" (click)="gotoSubmission()">
        <ion-avatar core-user-avatar [user]="profile" item-start [courseId]="courseId" [userId]="profile && profile.id"></ion-avatar>

        <h2><core-format-text [text]="submission.title" contextLevel="module" [contextInstanceId]="module.id" [courseId]="courseId"></core-format-text></h2>
        <p *ngIf="profile && profile.fullname">{{profile.fullname}}</p>
        <p *ngIf="submission.reviewedbycount">
            {{ 'addon.mod_workshop.receivedgrades' | translate }}: {{submission.reviewedbycount}} / {{submission.reviewedby.length}}
        </p>
        <p *ngIf="submission.reviewerofcount">
            {{ 'addon.mod_workshop.givengrades' | translate }}: {{submission.reviewerofcount}} / {{submission.reviewerof.length}}
        </p>
        <p *ngIf="!showGrade(submission.submissiongradeover) && showGrade(submission.submissiongrade)">
            {{ 'addon.mod_workshop.submissiongradeof' | translate:{$a: workshop.grade } }}: {{submission.submissiongrade}}
        </p>
        <p *ngIf="showGrade(submission.submissiongradeover)" class="addon-overriden-grade">
            {{ 'addon.mod_workshop.submissiongradeof' | translate:{$a: workshop.grade } }}: {{submission.submissiongradeover}}
        </p>
        <p *ngIf="access.canviewallsubmissions && showGrade(submission.gradinggrade)">
            {{ 'addon.mod_workshop.gradinggradeof' | translate:{$a: workshop.gradinggrade } }}: {{submission.gradinggrade}}
        </p>

        <ion-badge *ngIf="assessment && (showGrade(assessment.grade) || assessment.offline)" color="success">{{ 'addon.mod_workshop.assessedsubmission' | translate }}</ion-badge>
        <ion-badge *ngIf="assessment && !showGrade(assessment.grade) && !assessment.offline" color="danger">{{ 'addon.mod_workshop.notassessed' | translate }}</ion-badge>

        <ion-note item-end *ngIf="submission.timemodified">
            {{submission.timemodified | coreDateDayOrTime}}
            <div *ngIf="offline"><ion-icon name="time"></ion-icon> {{ 'core.notsent' | translate }}</div>
            <div *ngIf="submission.deleted"><ion-icon name="trash"></ion-icon> {{ 'core.deletedoffline' | translate }}</div>
        </ion-note>
    </a>
</core-loading>
